import { defineStore } from 'pinia'

export const useTargetStore = defineStore('target', {
	state: () => {
		return {
			targetType: null,
			currentId: '',
			currentData: {}
		}
	},
	getters: {
		getOptions: (state) => {
			return state.currentData
		}
	},
	actions: {
		clear() {
			this.targetType = null
			this.currentId = ''
			this.currentData = {}
		},
		setActiveTarget(data: any) {
			this.targetType = data.category
			this.currentId = data.i
			this.currentData = data
		},
		setOptions(data: any) {
			Object.assign(this.currentData, data)
		}
	}
})
